<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>XXXXXX管理平台 - 首页</title>
<%@ include file="taglibs.jsp"%>
<style type="text/css">
</style>
<script type="text/javascript">
	var firstNode;
	$(document).ready(function() {
		// 加载左边菜单
		loadMenu();
	});
		
	function loadMenu() {
		$.get(ctx + '/sys/menu/query/user?' + Math.random(), {
			userId : user.userId
		}, function(data) {
			var obj = $.parseJSON(data);

			$('#menuTree').tree({
				animate : true,
				lines : true,
				data : EasyUI.GenerateTreeData({data : obj.submenuList}),
				onSelect: function(node) {
					//alert(JSON.stringify(node))
					if ($(this).tree('isLeaf', node.target)) {
						if (node.id == firstNode.id) {
							var content = '<div title="欢迎使用"><h1 style="font-size: 24px;">欢迎！</h1><h1 style="font-size: 24px; color:red;"> Welcome ！</h1></div>';
							EasyUI.OpenTab({'id' : 'tabs', 'title' : node.text, 'content' : content, 'closable' : false});
						} else {
							EasyUI.OpenTab({'id' : 'tabs', 'title' : node.text, 'href' : node.attributes.url});
						}
					} else {
						$(this).tree('toggle', node.target);
					}
				},
				onLoadSuccess: function(node, data) {
					firstNode = $(this).tree('find', data[0].id);
					$(this).tree('select', firstNode.target);
				}
			});
		});
	}
</script>
</head>
<body class="easyui-layout">
	<!-- top -->
	<div data-options="region:'north',border:false" style="height: 80px;">north region</div>

	<!-- bottom -->
	<div data-options="region:'south',split:true" style="height: 30px;"></div>

	<!-- left -->
	<div data-options="region:'west',split:true,title:'欢迎使用'" style="width: 200px">
			<ul id="menuTree"></ul>
	</div>

	<!-- right 
	<div data-options="region:'east',split:true,collapsed:true,title:'East'" style="width:100px;padding:10px;">east region</div>
	-->
	<!-- body -->
	<div data-options="region:'center',border:false">
		<div id="tabs" class="easyui-tabs" data-options="fit:true, border:true">
		</div>
	</div>
</body>
</html>
